package client;

import java.lang.reflect.Proxy;

import srmi.RemoteInvoker;
import global.ShareContext;

public class NettyClient {
	
	private RemoteInvoker invoker;
	
	
	public NettyClient(ShareContext context, String host, int port){
		
		invoker = new RemoteInvoker(context, host, port);
	}
	
	@SuppressWarnings("unchecked")
	public <T> T getServerInterface(Class<T> clazz){
		if(!clazz.isInterface()) throw new RuntimeException("class ："+clazz+"不是一个接口");
		return (T)Proxy.newProxyInstance(invoker.getClass().getClassLoader(), new Class[]{clazz}, invoker);
	}
}
